//
//  DoorSystemHomeCollectionViewCell.m
//  RONGAO
//
//  Created by ZhangYeKun on 2017/2/24.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DoorSystemHomeCollectionViewCell.h"

@implementation DoorSystemHomeCollectionViewCell

- (void)setupViewWithConfig:(NSDictionary *)config{
    
    
    [self masLayoutSubview];
    [self.iconButton setImage:[UIImage imageNamed:config[@"nor_img"]] forState:UIControlStateNormal];
    [self.iconButton setImage:[UIImage imageNamed:config[@"sel_img"]] forState:UIControlStateSelected];
    self.iconNicknameLabel.text = config[@"title"];
    
}


- (UIButton *)iconButton{
    
    if (!_iconButton) {
        
        __weak UIView *superView = self;
        _iconButton = [[UIButton alloc]init];
        [superView addSubview:_iconButton];
        _iconButton.userInteractionEnabled = NO;
        
    }
    
    return _iconButton;
    
}

- (UILabel *)iconNicknameLabel{
    
    if (!_iconNicknameLabel) {
        
        __weak UIView *superView = self;
        _iconNicknameLabel = [[UILabel alloc]init];
        [superView addSubview:_iconNicknameLabel];
        [_iconNicknameLabel setFont:[UIFont systemFontOfSize:14.f]];
        _iconNicknameLabel.textColor = [UIColor grayColor];
        
    }
    
    return _iconNicknameLabel;
    
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self;
    [self.iconButton mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.height.and.width.mas_equalTo(50);
        
    }];
    [self.iconNicknameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.iconButton.mas_bottom);
        make.centerX.mas_equalTo(superView.mas_centerX);
        
    }];
    
}

@end
